<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta content="width=device-width, initial-scale=1" name="viewport" />
    <meta name="_xsrf" content="@{{.xsrf_token}}" />
    <title>BeeCustomAuth</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <link rel="stylesheet" href="/static/customAdmin/layui/css/layui.css" media="all">
    <link rel="stylesheet/less" type="text/css" href="/static/customAdmin/style/login.less" media="all">
    <link rel="stylesheet" href="//at.alicdn.com/t/font_1071313_j5163pevbe.css" media="all">
</head>
<body>
@{{ .LayoutContent }}
<script src="/static/js/less.min.js"></script>
<script src="/static/customAdmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '/static/customAdmin/'
    }).extend({
        index: 'lib/index'
    }).use(['index', 'login','form','admin'], async () => {
        const form = layui.form , admin = layui.admin  , $ = layui.$;

        await form.verify({
            password_confirmation: function (value, item) {
                if (!(/^[\S]{6,16}$/.test(value))) {
                    return '密码必须6到16位，且不能出现空格';
                } else if ($("input[name='password']").val() !== value) {
                    return '密码不一致';
                }
            }
            , password: [
                /^[\S]{6,16}$/
                , '密码必须6到16位，且不能出现空格'
            ]
        });

        form.on('submit(login_submit)', async (data) => {
           const res = await admin.post(@{{ urlfor "HomeController.DoLogin"}}, data.field);
            if (res.status) {
                parent.location.href = @{{ urlfor "HomeController.Index"}};
            }
        })
    });
</script>
</body>
</html>